/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.actions.client;

import com.myapp.entity.Client;
import com.myweb.WebAction;
import com.myweb.WebException;
import com.myweb.WebRequest;
import com.myweb.WebResponse;
import javax.persistence.EntityManager;

/**
 *
 * @author DTIT
 */
public class DeleteClient implements WebAction {

    private Long id;

    @Override
    public void prepare(WebRequest request) throws WebException {
        id = request.getLongNN("id");
    }

    @Override
    public EntityManager process(WebRequest req, WebResponse res, EntityManager em) throws Exception {
        Client client = em.getReference(Client.class, id);
        client.setDeleted(true);
        res.setMessage("Deleted client");
        res.setResult(client);
        return em;
    }
}
